<?php
$id				= gpc_getIntPost("id",$id);
$cName			= gpc_getStringPost("cName");
$Address		= gpc_getStringPost("Address");
$Phone			= gpc_getStringPost("Phone");
$Email			= gpc_getStringPost("Email");

$StartDate		= gpc_getStringPost("StartDate");
$EndDate		= gpc_getStringPost("EndDate");

$Place			= gpc_getIntPost("Place");
$Status			= gpc_getIntPost("Status");

$image			= gpc_getStringPost("ImgIntro");
$Link			= gpc_getStringPost("Link");
$description	= gpc_getStringPost("Description");
$OpenNewWindow	= gpc_getBoolPost("OpenNewWindow",0);

if(empty($StartDate))
{
	$StartDate=date("Y-m-d");
	$EndDate=$StartDate;
}

if($act=="insert")
{
    $sql_insert = "insert into
	tbladvertise(cName,cAddress,cPhone,cEmail,dStartDate,dEndDate,dPostDate,cImageLink,iOpenNew,
				cUrlString,iPlace,iStatus,cDescription,cLanguage)
		values('$cName','$Address','$Phone','$Email','$StartDate','$EndDate','$postdate','$image','$OpenNewWindow',
				'$Link','$Place','$Status','$description','$language')";

    $dbsql->query($sql_insert);

    //tracking:
    Insert_Tracking("Insert Advertise: ".$cName);
    page_transfer("Add Advertise Success");
}
elseif($id>0)
{
    $sql_update = "update tbladvertise set
    			cName='$cName',
    			cAddress='$Address',
    			cPhone='$Phone',
    			cEmail='$Email',
    			dStartDate='$StartDate',
    			dEndDate='$EndDate',
    			cImageLink='$image',
    			cUrlString='$Link',
    			iPlace='$Place',
    			iStatus='$Status',
    			iOpenNew	= '$OpenNewWindow',
    			cDescription='$description'
    		where iAdvertiseId='$id'";

    $dbsql->query($sql_update);

    //tracking:
    Insert_Tracking("update Advertise: ".$cName);
    page_transfer("update Advertise Success!",getUrlBack());
}
exit();
?>
